package day5;

import java.util.*;

/**
 * @author oldliu
 * @since 1.0
 */
public class MapTest4 {
    public static void main(String[] args) {
        Map m=new HashMap();
        m.put("cat","猫");
        m.put("dog","狗");
        m.put("tiger","老虎");
        m.put("goldenfish","金鱼");
        m.put("tiger","华南虎");
        m.put("table","桌子");
        m.put("desk","桌子");
        m.put("nothing",null);
        m.put(null,"zero");//?
        System.out.println("所有的key：？");
        Set set = m.keySet();
        System.out.println(set);
        System.out.println("所有的value:");
        Collection values = m.values();
        System.out.println(values);
        Scanner in=new Scanner(System.in);
        System.out.print("请输入英文：");
        String eng=in.next();

        if(!m.containsKey(eng)){
            System.out.println("字典中没有");
        }else{
            Object zhong=m.get(eng);
            System.out.println(eng+"对应的中文是"+zhong);
        }

//        if(zhong==null){//不全面
//            System.out.println("字典中没有");
//        }else{
//            System.out.println(eng+"对应的中文是"+zhong);
//        }
    }
}
